##############################################################
#Figure F3: Hurricane Proximity and Roads
##############################################################

infra1 <- read.dta13("./temp/figf31data.dta")

newdf <- infra1 %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(5,4,3,2,6,1)
newdf$type <- "State Spending Infrastructure"
g2<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=coef, ymin=ci_upper, 
                                          ymax=ci_lower), color="black", size=1.2, lwd=1.2, fatten=2, fill="white", shape=21) +
  ylim(-1,.5) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6"), labels= c("[500,30)", "[400,30)", "[300,30)", "[200,30)", "[100,30)", "[50,30)")) + 
  xlab("Distance Band")  + ylab(" ") + 
  geom_hline(yintercept=0, col="black", lwd=.5, lty="dashed", alpha=.6)  + 
  theme_bw() + theme(panel.grid.major.y = element_blank(),
                     panel.grid.minor.y = element_blank()) +
  facet_wrap(~type) + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

g2

rm(infra1, newdf)

infra2 <- read.dta13("./temp/figf32data.dta")

newdf <- infra2 %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(5,4,3,2,6,1)
newdf$type <- "Congress Transportation Act"
g1<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=coef, ymin=ci_upper, 
                                          ymax=ci_lower), color="black", size=1.2, lwd=1.2,  fatten=2, fill="white", shape=21) +
  ylim(-1,.5) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6"), labels= c("[500,30)", "[400,30)", "[300,30)", "[200,30)", "[100,30)", "[50,30)")) + 
  geom_hline(yintercept=0, col="black", lwd=.5, lty="dashed", alpha=.6)  + 
  theme_bw() + theme(panel.grid.major.y = element_blank(),
                     panel.grid.minor.y = element_blank()) +
  facet_wrap(~type) +  ylab("Estimate on ...") + xlab(" ") + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

g1
rm(infra2, newdf)

infra3 <- read.dta13("./temp/figf33data.dta")

newdf <- infra3 %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(5,4,3,2,6,1)
newdf$type <- "Local: Roads Satisfaction"
g3<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=coef, ymin=ci_upper, 
                                          ymax=ci_lower), color="black", size=1.2, lwd=1.2, fatten=2, fill="white", shape=21) +
  ylim(-1,.5) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6"), labels= c("[500,30)", "[400,30)", "[300,30)", "[200,30)", "[100,30)", "[50,30)")) + 
  geom_hline(yintercept=0, col="black", lwd=.5, lty="dashed", alpha=.6)  + 
  theme_bw() + theme(panel.grid.major.y = element_blank(),
                     panel.grid.minor.y = element_blank()) +
  facet_wrap(~type) + xlab(" ") + ylab(" ") + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

g3
ggarrange(g1,g2,g3, ncol=3)
ggsave("./figures/figf3.pdf")
